package ssm.codegen;

import java.io.IOException;

import org.apache.commons.configuration.ConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import ssm.codegen.service.CodeGeneratorService;

public class CodeGenerator {

	public static void main(String[] args) throws IOException, ConfigurationException {

		final Logger logger = LoggerFactory.getLogger(CodeGenerator.class);

		logger.info("begin generate...");

		ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:spring-context.xml");
		String[] beanNames = ctx.getBeanDefinitionNames();
		for (String beanName : beanNames) {
			logger.debug("...................{}", beanName);
		}

		CodeGeneratorService codeGenerator = ctx.getBean("codeGeneratorServiceImpl", CodeGeneratorService.class);

		codeGenerator.generateDomainFiles();
		// codeGenerator.generateDaoFiles();
		// codeGenerator.generateDaoSqlSessionImplFiles();
		codeGenerator.generateDaoMyBatisMapperFiles();
		// codeGenerator.generateMyBatisConfigFile(true);
		// ///// codeGenerator.generateDaoJdbcImplFiles();
		// codeGenerator.generateServiceFiles();
		// codeGenerator.generateServiceImplFiles();
		// codeGenerator.generateFacadeFile(true);
		// codeGenerator.generateFacadeImplFile(true);
		logger.info("end generate...");
	}
}
